<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/_fragments :: head(~{::title})">
    <title>标签新增</title>
</head>

<body>
    <!--导航-->
    <nav class="ui inverted attached segment m-padding-tb-mini m-shadow-small">
        <div class="ui container"><!--表示一个容器-->
            <div class="ui inverted secondary stackable menu">
                <!--这个stackable使得适应手机端-->
                <h2 class="ui teal header item">管理后台</h2>
                <a href="#" th:href="@{/blogsa}" class="m-item item m-mobile-hide" ><i class="home icon"></i>博客</a>
                <a href="#" th:href="@{/totype}" class="m-item item m-mobile-hide"><i class="idea icon"></i>分类</a>
                <a href="#" th:href="@{/toTageaka}" class="active m-item item m-mobile-hide"><i class="tags icon"></i>标签</a>
                <div class="right m-item m-mobile-hide menu">
                    <div class="ui dropdown item">
                        <div class="text">
                            <img class="ui avatar image" src="https://unsplash.it/100/100?image=1005"> RobinZ
                        </div>
                        <i class="dropdown icon"></i>
                        <div class="menu">
                            <a href="#" th:href="@{/admin/logout}" class="item">注销</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <a href="#" class="ui menu toggle black icon button m-right-top m-mobile-show">
            <i class="sidebar icon"></i>
        </a>
    </nav>

    <!--发布Or编辑-->
    <div class="ui container">
        <div class="ui teal inverted attached pointing menu">
            <a href="#" th:href="@{/admin/tags/input}" class="active item">发布</a>
            <a href="#" th:href="@{/admin/tags}" class="item">列表</a>
        </div>
    </div>
    <!--中间内容-->
    <div class=" m-container-small m-padding-tb-big">
        <div class="ui container">      <!--初始化为type实体类，如果没id，则进行添加，若有id，则进行更新-->
<!--

-->
            <form  action="#" th:object="${tag}" th:action="${tag}==null ? @{insertTag} : @{UpdateTag(id=*{id})}"  method="post" class="ui form">

                <div class="field">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label">名称</label>
                        <!--设置name为text -->
                        <input type="text" name="name" th:value="${tag?.name}" placeholder="标签名称" >
                    </div>
                </div>
                <div class="ui error message"></div>

                <div class="ui negetive message" th:unless="${#strings.isEmpty(msg)}">
                    <i class="close icon"></i>
                    <div class="header">验证失败：</div>
                    <p th:text="${msg}">对不起，操作失败！</p>
                </div>


                <div class="ui right aligned container">
                    <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                    <button class="ui teal button">提交</button>
                </div>
            </form>
        </div>
    </div>

    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <!--底部脚本元素-->
    <footer class="ui inverted vertical segment m-padding-tb-massive">
        <div class="ui center aligned container">
            <div class="ui inverted divided stackable grid"><!--分成16份-->
                <div class="three wide column">
                    <div class="ui inverted link list">
                        <div class="item">
                            <img src="./static/images/wechat.png" th:src="@{images/wechat.png}" class="ui rounded image" alt="" style="width: 110px">
                        </div>
                    </div>
                </div>
                <div class="three wide column">
                    <h4 class="ui inverted header m-text-thin m-text-spaced ">最新博客</h4>
                    <div class="ui inverted link list">
                        <a href="#" class="item">用户故事（User Story）</a>
                        <a href="#" class="item">用户故事（User Story）</a>
                        <a href="#" class="item">用户故事（User Story）</a>
                    </div>
                </div>
                <div class="three wide column">
                    <h4 class="ui inverted header m-text-thin m-text-spaced ">联系我</h4>
                    <div class="ui inverted link list">
                        <a href="#" class="item">Email: 498166439@qq.com</a>
                        <a href="#" class="item">QQ: 498166439</a>
                        <a href="#" class="item">Wechat: robinz1996</a>
                    </div>
                </div>
                <div class="seven wide column">
                    <h4 class="ui inverted header m-text-thin m-text-spaced ">Blog</h4>
                    <p class="m-text-thin m-text-spaced m-opacity-mini">这是我的个人博客，会分享编程，刷题，思考相关任何内容，希望可以让大家一起WDNMD...</p>
                </div>
            </div>
            <div class="ui inverted section divider"></div>
            <p class="m-text-thin m-text-spaced m-opacity-mini">Copyright @ 2020 - 2021 RobinZ Designed By RobinZ</p>
        </div>
    </footer>

    <th:block th:replace="admin/_fragments :: script"></th:block>

    <script>

        $('.menu.toggle').click(function() {
            $('.m-item').toggleClass('m-mobile-hide');
        });

        $('.ui.dropdown').dropdown({
            on : 'hover'
        });
        //检验信息是否为空，为空推送错误报告
        $('.ui.form').form({
            fields : {
                name : {
                    identifier : 'name',
                    rules : [{
                        type : 'empty',
                        prompt : '标签：请填写标签'
                    }]
                }
            }
        });

        //消息提示关闭初始化
        $('.message .close').on('click', function () {
            $(this)
                .closest('.message')
                .transition('fade');
        });
    </script>
</body>
</html>